package com.cssy.yd.logic.dao.impl;

import java.util.List;
import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.cssy.yd.logic.dao.LogicWhAffstockDAO;
import com.cssy.yd.logic.entity.LogicWhAffstockDO;
import com.cssy.yd.logic.vo.LogicWhAffstockVO;
import com.plat.helper.SearchConditions;

/**
 * 数据访问对象实现类
 * @since 2012-12-26
 */
public class LogicWhAffstockDAOImpl extends SqlMapClientDaoSupport implements LogicWhAffstockDAO {

    /**
     * 插入数据
     * @param logicWhAffstockDO
     * @return 插入数据的主键
     */
    public String insertLogicWhAffstockDO(LogicWhAffstockDO logicWhAffstockDO) throws DataAccessException {
        Object id = getSqlMapClientTemplate().insert("LogicWhAffstock.insert", logicWhAffstockDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param logicWhAffstockDO
     * @return 查出的记录数
     */
    public Integer countLogicWhAffstockDOByExample(LogicWhAffstockDO logicWhAffstockDO) throws DataAccessException {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicWhAffstock.countByDOExample", logicWhAffstockDO);
        return count;
    }

    /**
     * 更新记录
     * @param logicWhAffstockDO
     * @return 受影响的行数
     */
    public Integer updateLogicWhAffstockDO(LogicWhAffstockDO logicWhAffstockDO) throws DataAccessException {
        int result = getSqlMapClientTemplate().update("LogicWhAffstock.update", logicWhAffstockDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param logicWhAffstockDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<LogicWhAffstockDO> findListByExample(LogicWhAffstockDO logicWhAffstockDO) throws DataAccessException {
        List<LogicWhAffstockDO> list = getSqlMapClientTemplate().queryForList("LogicWhAffstock.findListByDO", logicWhAffstockDO);
        return list;
    }

    /**
     * 根据主键获取logicWhAffstockDO
     * @param id
     * @return logicWhAffstockDO
     */
    public LogicWhAffstockDO findLogicWhAffstockDOByPrimaryKey(String id) throws DataAccessException {
        LogicWhAffstockDO logicWhAffstockDO = (LogicWhAffstockDO) getSqlMapClientTemplate().queryForObject("LogicWhAffstock.findByPrimaryKey", id);
        return logicWhAffstockDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteLogicWhAffstockDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicWhAffstock.deleteByPrimaryKey", id);
        return rows;
    }
    
    @Override
	public List<LogicWhAffstockDO> find(SearchConditions scs)
			throws DataAccessException {
		List<LogicWhAffstockDO> list = getSqlMapClientTemplate().queryForList("WhAffstock_ex.find", scs);
		return list;
	}

	@Override
	public Integer count(SearchConditions scs) throws DataAccessException {
		 Integer count = (Integer) getSqlMapClientTemplate().queryForObject("WhAffstock_ex.count", scs);
		return count;
	}

	@Override
	public List<LogicWhAffstockVO> findForWareHouseStock(SearchConditions scs)
			throws DataAccessException {
		List<LogicWhAffstockVO> list = getSqlMapClientTemplate().queryForList("LogicWhAffstock.findListBySearchConForWareHouseStock", scs);
		return list;
	}

	@Override
	public Integer findForWareHouseStockCount(SearchConditions scs)
			throws DataAccessException {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicWhAffstock.findListBySearchConForWareHouseStockCount", scs);
		return count;
	}
	
	@Override
	public List<LogicWhAffstockDO> findwhcode(String s)
			throws DataAccessException {
		List<LogicWhAffstockDO> list = getSqlMapClientTemplate().queryForList("WhAffstock_ex.findwhcode", s);
		return list;
	}

	@Override
	public List<String> findbatch(Map map) throws DataAccessException {
		List<String> list = getSqlMapClientTemplate().queryForList("WhAffstock_ex.findbatch", map);
		return list;
	}
	
	@Override
	public List<LogicWhAffstockDO> stockGather(SearchConditions scs) throws DataAccessException {
		List<LogicWhAffstockDO> list = getSqlMapClientTemplate().queryForList("WhAffstock_ex.stockGather", scs);
		return list;
	}
	
	@Override
	public Integer stockGatherCount(SearchConditions scs) throws DataAccessException {
		 Integer count = (Integer) getSqlMapClientTemplate().queryForObject("WhAffstock_ex.stockGatherCount", scs);
		return count;
	}
	
	@Override
	public List<LogicWhAffstockDO> findByBatchAll(Map<String, Object> map) throws DataAccessException {
		List<LogicWhAffstockDO> list = getSqlMapClientTemplate().queryForList("WhAffstock_ex.findByBatchAll", map);
		return list;
	}
	@Override
	public List<LogicWhAffstockDO> findBySearchBatch(SearchConditions scs) throws DataAccessException {
		List<LogicWhAffstockDO> list = getSqlMapClientTemplate().queryForList("WhAffstock_ex.findBySearchBatch", scs);
		return list;
	}
}